/*
 * Copyright 2013 Sigurd Randoll <srandoll@digiway.de>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.digiway.rapidbreeze.server.model.download;

import java.util.List;

/**
 * A Repository providing methods to retrieve and store {@linkplain Download}
 * instances.
 *
 * @author Sigurd Randoll <srandoll@digiway.de>
 */
public interface DownloadRepository {

    /**
     * Retrieves a list of all {@linkplain Download} instances which are
     * currently active in the system. The list will be sorted by the date of
     * creation.
     *
     * @return a list instance, never null
     */
    public List<Download> getDownloads();

    /**
     * Checks if the {@linkplain Download} with the given identifier exists.
     *
     * @param identifier
     * @return true if exists
     */
    public boolean hasDownload(String identifier);

    /**
     * Returns the {@linkplain Download} instance with the given identifier.
     *
     * @param identifier
     * @return {@linkplain Download} instance
     * @throws IllegalArgumentException if the download with the identifier does
     * not exist.
     */
    public Download getDownload(String identifier);

    /**
     * Adds a new {@linkplain Download} instance to the repository.
     *
     * @param download
     */
    public void add(Download download);

    /**
     * Removes the given {@linkplain Download} from the repository.
     *
     * @param download
     */
    public void remove(Download download);

    /**
     * Updates the given {@linkplain Download} in the repository. The
     * {@linkplain Download} instance must be added before.
     *
     * @param download
     * @throws IllegalArgumentException if the {@linkplain Download} instance
     * hasn't beent added before.
     */
    public void update(Download download);

    /**
     * Deletes the given {@linkplain Download} instance from the repository.
     *
     * @param download
     * @throws IllegalArgumentException if the instance hasn't been added
     * before.
     */
    public void delete(Download download);

    /**
     * Clears all {@linkplain Download} instances from the repository.
     */
    public void clearAll();
}
